package com.yyfax.pay.config.data.service.impl;

import java.util.ArrayList;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.yyfax.framework.service.CacheService;
import com.yyfax.pay.common.constants.CacheName;
import com.yyfax.pay.config.data.service.BankConfigExtService;
import com.yyfax.pay.config.data.service.BankConfigService;
import com.yyfax.pay.config.data.service.MerchantConfigService;
import com.yyfax.pay.config.data.service.MerchantPaymentService;
import com.yyfax.pay.config.data.service.PaymentQuotaService;
import com.yyfax.pay.config.data.service.PaymentRouteService;
import com.yyfax.pay.config.model.po.BankConfigExtPO;
import com.yyfax.pay.config.model.po.BankConfigPO;
import com.yyfax.pay.config.model.po.MerchantConfigPO;
import com.yyfax.pay.config.model.po.MerchantPaymentPO;

@Service
public class PaymentCacheService {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	@Qualifier("payCacheService")
	private CacheService cacheService;

	@Autowired
	private BankConfigService bankConfigService;

	@Autowired
	private MerchantConfigService merchantConfigService;

	@Autowired
	private MerchantPaymentService merchantPaymentService;

	@Autowired
	private PaymentQuotaService paymentQuotaService;

	@Autowired
	private PaymentRouteService paymentRouteService;

	@Autowired
	private BankConfigExtService bankConfigExtService;

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@PostConstruct
	public void init() {

		try {

			cacheService.delete(CacheName.BANK_CONFIG);
			cacheService.delete(CacheName.MERCHANT_CONFIG);
			cacheService.delete(CacheName.MERCHANT_PAYMENT);
			cacheService.delete(CacheName.PAYMENT_QUOTA);
			cacheService.delete(CacheName.PAYMENT_ROUTE);
			cacheService.delete(CacheName.BANK_CONFIG_EXT);

			bankConfigService.queryForList();

			merchantConfigService.queryForList();

			merchantPaymentService.queryForList();

			paymentQuotaService.queryForList();

			paymentRouteService.queryForList();

			bankConfigExtService.queryForList();

		} catch (Exception e) {
			logger.error("获取缓存错误{}", e);
		}

	}

}
